#pragma once

template <typename T> class singleton
{
private:
	singleton( const singleton<T>& );

	singleton<T>& operator = ( const singleton<T>& );

public:
	singleton()
	{
		assert( !m_singleton );
		m_singleton = static_cast<T*>( this );
	}

	virtual ~singleton()
	{
		assert( m_singleton );
		m_singleton = 0;
	}

	static T& get_singleton()
	{
		assert( m_singleton );
		return *m_singleton;
	}

	static T* get_singleton_ptr()
	{
		assert( m_singleton );
		return m_singleton;
	}

protected:
	static T* m_singleton;
};